import json

class S:
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def __str__(self):
        # return "{name: %s, age: %s}" % (self.name, self.age)
        return json.dumps(self, default=lambda obj: obj.__dict__)

    __repr__ = __str__


ss = [S("Jack", 10), S("Lucy", 18)]
print(ss)
